package top.alanshelby.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import top.alanshelby.entity.Goods;

import java.util.ArrayList;
import java.util.List;

@Controller
public class GoodsController {

    @RequestMapping(value = "queryGoods")
    public ModelAndView queryGoods() {
        ModelAndView modelAndView = new ModelAndView();
        // 构造演示数据
        List<Goods> goodsList = new ArrayList<>();
        Goods goods1 = new Goods();
        goods1.setName("小米8SE");
        goods1.setPrice(1999f);
        goods1.setDetail("全面屏智能手机 6GB+64GB 灰色 全网通4G 双卡双待");
        Goods goods2 = new Goods();
        goods2.setName("Apple iPad");
        goods2.setPrice(3359f);
        goods2.setDetail("平板电脑 2018年新款9.7英寸（128G WLAN版/A10 芯片/Retina显示屏/Touch ID MRJP2CH/A）金色");
        goodsList.add(goods1);
        goodsList.add(goods2);
        modelAndView.addObject("goodsList", goodsList);
        modelAndView.setViewName("goodsList");
        return modelAndView;
    }
}
